package character;

import java.util.List;
import java.util.ArrayList;
/**
 * 
 * @author Matt
 * 
 * This corresponds to a State within an NFA.  A state keeps track of:
 * int idNum (State #)
 * List validInputs (A list of valid inputs required to reach the state)
 * Boolean finishState (A boolean that designates if it is or is not a finishing state)
 *
 */
public class State {

	//State is a valid state based on the RegEx.
	
	//A state consists of:
	/**
	 * an integer ID, 
	 * a list of validInputs (for other states to reach them),
	 * a boolean that designates if the state is a finishing state.
	 */
	int idNum;	
	List<Input> validInputs, oldInputs;	
	boolean isFinishState;
	boolean isStartState;
	boolean processed;
	List<Integer> IDList;
	//CONSTRUCTORS: 
	/**
	 * Creates a new class from an int ID and a List of inputs
	 * @param idNum
	 * @param inputs
	 */
	
	public State(int idNum){
		this.idNum =idNum;
		this.validInputs = new ArrayList();
		this.isFinishState = false;
		this.isStartState = false;
		this.IDList = new ArrayList<Integer>();
		this.oldInputs = new ArrayList<Input>();
	}
	
	public State(int idNum, List<Input> inputs){
		this.idNum = idNum;
		this.validInputs = inputs;
		this.isFinishState = false;
		this.isStartState = false;
		this.IDList = new ArrayList<Integer>();
		this.oldInputs = new ArrayList<Input>();
	}

	
	//METHODS:
	public void addOldInput(Input i){
		oldInputs.add(i);
	}
	public List<Input> getOldInputs(){
		return oldInputs;
	}
	public void addID(int a){
		IDList.add(a);
	}
	public List<Integer> getIDList(){
		return IDList;
	}
	/**
	 * Returns the identification
	 * @return
	 */
	public int getID() {
		return idNum;
	}
	/**
	 * sets the identification 
	 * @param identification
	 */
	public void setID(int identification) {
		this.idNum = identification;
	}
	/**
	 * returns a List of valid inputs
	 * @return
	 */
	public List<Input> getInputs() {
		return validInputs;
	}
	/**
	 * Sets a List of valid inputs
	 * @param validInputs
	 */
	public void setInputs(List<Input> validInputs) {
		this.validInputs = validInputs;
	}
	
	/**
	 * Adds a new input (that is a charSpec)
	 * @param newInput
	 */
	public void addInput(Input newInput){
			this.validInputs.add(newInput);
	}
	
	/**
	 * returns boolean of finish state
	 * @return 
	 */
	public boolean isFinishState() {
		return isFinishState;
	}
	/**
	 * sets whether or not this is a finishing state.
	 * @param finishState
	 */
	public void setFinishState(boolean finishState) {
		this.isFinishState = finishState;
	}
	/**
	 * Determines if state is a start state
	 * @return
	 */
	public boolean isStartState(){
		return isStartState;
	}
	
	/**
	 * Sets current state to a start state
	 * @param startState
	 */
	public void setStartState(boolean startState){
		this.isStartState=startState;
	}
}
